package GUILayer;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JLabel;
import javax.swing.Timer;

public class Clock implements ActionListener 
{
// All other steps should have their code added here.
	JLabel lblTime = new JLabel();

	SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");

	Timer timer;

	public Clock() 
	{

	// Get the current system time and display it
	// according to the format we defined.
	lblTime.setText(sdf.format(new Date(System.currentTimeMillis())));

	timer = new Timer(1000, this);
	timer.setRepeats(true);
	timer.start();

	}

	public void actionPerformed(ActionEvent e) 
	{
		// If the timer caused this event.
		if (e.getSource().equals(timer)) 
		{
			// Then set a new time.
			lblTime.setText(sdf.format(new Date(System.currentTimeMillis())));
		}

	}
	
	public Clock main() {
		// TODO Auto-generated method stub
		return new Clock();
	}
}